var checkMailorMobile = "/member/center/checkMailorMobile";
var bindMailorMobile = "/member/center/bindMailorMobile";
if (typeof window.IS_MOBILE !== "undefined") {
    checkMailorMobile = "/mobile/member/center/checkMailorMobile";
    bindMailorMobile = "/mobile/member/center/bindMailorMobile"
}
$(document).ready(function() {
    $("#bindwechat").click(function() {
        $("#popup-verifywechat").dialog({
            title: "绑定微信号",
            width: 620
        })
    });
    $("#editwechat").click(function() {
        $("#popup-verifywechat").dialog({
            title: "修改微信号",
            width: 620
        })
    })
});
function checkUserWechat() {
    var a = $.trim($("#txtWechat").val());
    if (a == "") {
        dialog.error("消息", "用户微信号不能为空！");
        //alert("用户微信号不能为空！");
        return false
    }
    $("#btnCheckWechat").attr("disabled", "disabled");
    $.post('/index.php/UserCenter/checkWechat', {
        type: 0,
        userwechat: a
    }, function(b) {
        if (b.success) {
            bindWechat()
        } else {
            dialog.error("消息", "该微信号码已绑定，不能重复使用！");
            //alert("该微信号码已绑定，不能重复使用！");
            $("#btnCheckWechat").removeAttr("disabled")
        }
    },'json')
}
function bindWechat() {
    $.post('/index.php/UserCenter/bindWechat', {
        type: 0,
        userwechat: $.trim($("#txtWechat").val())
    }, function(a) {
        if (a.success) {
                  
            //dialog.alert("消息", a.message, null, "/")
        	dialog.alert("消息", a.message);
        	setTimeout(function(){
        		/*Window.location.href="/index.php/member/index#/center/index/1";
        		location.href="user.php"; */
        		window.location.reload()
        	},3000);
        } else {
            dialog.error("消息", a.message)
            //alert(a.message))
        }
    },'json')
}
;